package com.linkoog.devtools.intellij.wizard;

import com.intellij.openapi.project.Project;
import lombok.Getter;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;


public class WizardContext {

    @Getter
    private Project project;

    private final LinkedHashMap<String,Object> dataMap;

    public WizardContext(){
        this.dataMap = new LinkedHashMap<>();
    }

    public void put(String key, Object value){
        if (key != null && key.length() > 0 ){
            this.dataMap.put(key, value);
        }
    }

    public void putAll(Map<String,Object> dataMap){
        if (dataMap != null){
            this.dataMap.putAll(dataMap);
        }
    }


    public Object get(String key, Object... defaultVal){
        Object val = this.dataMap.get(key);
        if (val == null && defaultVal != null && defaultVal.length > 0){
            return defaultVal[0];
        }
        return val;
    }

    public Map<String, Object> getDataMap() {
        return new LinkedHashMap<>(this.dataMap);
    }


}
